JDK 8 : Install
2015/03/15 |
Install Java SE Development Kit 8 (JDK8) and build Java Environment.
|
|
[1] | Download and install JDK 8. Make sure the latest version and source URL of JDK on Oracle download site. |
[root@dlp ~]#
[root@dlp ~]# curl -LO -H "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u40-b26/jdk-8u40-linux-x64.rpm" rpm -Uvh jdk-8u40-linux-x64.rpm Preparing... ############################## [100%] 1:jdk1.8.0_40 ############################## [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... jfxrt.jar...
[root@dlp ~]#
vi /etc/profile # add follows to the end
export JAVA_HOME=/usr/java/default export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar source /etc/profile
|
[2] | Create a test program and make sure if it works normally. |
[root@dlp ~]#
vi day.java import java.util.Calendar; class day { public static void main(String[] args) { Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int month = cal.get(Calendar.MONTH) + 1; int day = cal.get(Calendar.DATE); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); System.out.println(year + "/" + month + "/" + day + " " + hour + ":" + minute); } } javac day.java # compile [root@dlp ~]# java day # execute 2015/3/15 20:30 |